package com.sixfoot.facade.organization;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sixfoot.dao.OrganizationRepository;
import com.sixfoot.domain.Organization;
import com.sixfoot.foundation.mapping.adapter.AbstractDtoAdapter;

@Component
public class OrganizationAdapter extends AbstractDtoAdapter<Organization, OrganizationDto, OrganizationInputArgs> {
	@Autowired
	private OrganizationRepository organizationRepository;
	
	@Override
	public Organization postConvertToDo(OrganizationInputArgs i, Organization d) {
		Organization parent = organizationRepository.findOne(i.getParentId());
		d.setParent(parent);
		return postUpdate(i, d);
	}

	@Override
	public Organization postUpdate(OrganizationInputArgs i, Organization d) {
		return d;
	}

}
